import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'indexMonitoringM',

  state: {},

  effects: {
    //获取指数名称
    *queryByCode({ payload, callback }, { call, put }) {
      const res = yield call(api.indexMonitoring.queryByCode, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        message.error(res?.msg);
      }
    },
    // 获取监控主表统计数据
    *getList({ payload, callback }, { call, put }) {
      const res = yield call(api.indexMonitoring.getList, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        message.error(res?.msg);
      }
    },
    // 获取监控主表统计数据
    *getIndexTable({ payload, callback }, { call, put }) {
      const res = yield call(api.indexMonitoring.getIndexTable, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        message.error(res?.msg);
      }
    },
    // 获取行业看板统计数据
    *getIndustryTable({ payload, callback }, { call, put }) {
      const res = yield call(api.indexMonitoring.getIndustryTable, payload);
      if (res && res.code == 0) {
        callback(res.data);
      } else {
        message.error(res?.msg);
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
